package com.liuyun.util;

import lombok.SneakyThrows;

import java.util.Base64;

/**
 * <p>
 * Copyright: (C), 2021/1/4 22:08
 * <p>
 * <p>
 * Company Information & Data Security Solutions Co., Ltd.
 *
 * @author LiuYun liujw@idss-cn.com
 * @version 1.0
 */
public class Base64Util {
    /**
     * base64加密
     *
     * @return
     */
    @SneakyThrows
    public static String encode2Base64(byte[] key) {
        return Base64.getEncoder().encodeToString(key);
    }

    /**
     * base64解密
     *
     * @return
     */
    @SneakyThrows
    public static byte[] decodeFromBase64(String base64Str) {
        return Base64.getDecoder().decode(base64Str);
    }
}
